home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / art3dPaintCheckDefaultBrush. < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.9 KB  |  153 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.  
  18. //
  19. //  Alias|Wavefront Script File
  20. //  MODIFY THIS AT YOUR OWN RISK
  21. //
  22. //  Creation Date:  16 April 2001
  23. //
  24. //  Procedure Name:
  25. //      art3dPaintCheckDefautBrush
  26. //
  27. //  Description:
  28. //      Makes sure that the nodes that store the default paint effects brushes
  29. //        for paint, blur, and smear have been created.
  30. //
  31. //  Input Arguments:
  32. //      $mode - mode to make sure default brush exists for ("Paint", "Smear", 
  33. //                or "Blur")
  34. //
  35. //  Return Value:
  36. //      None.
  37. //
  38. global proc art3dPaintCheckDefaultBrush( string $mode ) {
  39.     string $defaultBrushName;
  40.     string $defaultBrushScript;
  41.  
  42.     // Nodes which store the saved brush settings
  43.     //
  44.     global string $gArt3dPaintLastPaintBrush    = "art3dPaintLastPaintBrush";
  45.     global string $gArt3dPaintLastBlurBrush        = "art3dPaintLastBlurBrush";
  46.     global string $gArt3dPaintLastSmearBrush    = "art3dPaintLastSmearBrush";
  47.     
  48.     // These are the names of the brushes that we will use as defaults
  49.     //
  50.     string $defaultPaintBrush = "airbrush/defaultPaint";
  51.     string $defaultSmearBrush = "airbrush/defaultSmear";
  52.     string $defaultBlurBrush  = "airbrush/defaultBlur";
  53.  
  54.     // Names that the default brush had when the saved settings were in place
  55.     // (e.g. fire1)
  56.     //
  57.     global string $gArt3dPaintLastPaintBrushName;
  58.     global string $gArt3dPaintLastBlurBrushName;
  59.     global string $gArt3dPaintLastSmearBrushName;
  60.  
  61.     // Check if the default brushes exist
  62.     //
  63.     int $defaultPaintExists, $defaultSmearExists, $defaultBlurExists;
  64.     
  65.     switch ( $mode ) {
  66.         case "Paint":
  67.             $defaultBrushName = $gArt3dPaintLastPaintBrush;
  68.             $defaultBrushScript = $defaultPaintBrush;
  69.             $gArt3dPaintLastPaintBrushName = basename( $defaultBrushScript, "" );
  70.             break;
  71.         case "Smear":
  72.             $defaultBrushName = $gArt3dPaintLastSmearBrush;
  73.             $defaultBrushScript = $defaultSmearBrush;
  74.             $gArt3dPaintLastSmearBrushName = basename( $defaultBrushScript, "" );
  75.             break;
  76.         case "Blur":
  77.             $defaultBrushName = $gArt3dPaintLastBlurBrush;
  78.             $defaultBrushScript = $defaultBlurBrush;
  79.             $gArt3dPaintLastBlurBrushName = basename( $defaultBrushScript, "" );
  80.             break;
  81.         default:
  82.             error "unsupported mode in art3dPaintCheckDefaultBrush";
  83.     }
  84.  
  85.     if ( `objExists $defaultBrushName` ) {
  86.         // The brush node already exists;
  87.         return;
  88.     }
  89.  
  90.     // Figure out where the brushes live
  91.     //
  92.     string $brushDir = getenv( "MAYA_LOCATION" ) + "/brushes/";
  93.  
  94.     // Make a copy of the existing selection
  95.     //
  96.     string $currSelection[] = `ls -sl`;
  97.  
  98.     // Make a copy of the current brush so that we can put it back
  99.     //
  100.     string $defaultName = getDefaultBrush();
  101.     string $copyReasults[] = `duplicate $defaultName`;
  102.     string $defaultCopy = $copyReasults[0];
  103.  
  104.     // Create the node where we will store the brush settings in the future
  105.     //
  106.     createNode "brush" -n $defaultBrushName;
  107.     int $ok = false;
  108.  
  109.     string $brushBaseName = basename( $defaultBrushScript, "" ) + ".mel";
  110.     if ( `exists $brushBaseName` ) {
  111.         // The paint brush is in our script path.  Use that instead.  This
  112.         // will allow users to override the default brush by putting a 
  113.         // brush script in their own script directory
  114.         // 
  115.         if ( !catch( eval( "source " + $brushBaseName ) ) ) {
  116.             $ok = true;
  117.         }
  118.     } 
  119.     if ( !$ok ) {
  120.         // Need to pick up the brush out of the brushes directory
  121.         //
  122.         if ( !catch( eval( "source \"" + $brushDir + $defaultBrushScript + ".mel\"" ) ) ) {
  123.             $ok = true;
  124.         }
  125.     }
  126.  
  127.     if ( !$ok ) {
  128.         error ( "Failed to load default paint effects paint brush: " + $defaultBrushScript );
  129.     }
  130.  
  131.     // Store the brush settings for the default brush we just loaded into our 
  132.     // save node
  133.     //
  134.     copyNode( getDefaultBrush(), $defaultBrushName );
  135.  
  136.     // Put back the old default brush
  137.     //
  138.     brushPresetSetup();
  139.     copyNode( $defaultCopy, getDefaultBrush() );
  140.     rename( getDefaultBrush(), $defaultName );
  141.     delete $defaultCopy;
  142.  
  143.     // Set the paint effects brush mode.
  144.     //
  145.     string $currContext = `currentCtx`;
  146.     art3dPaintCtx -e -brushtype "effectsBrush" $currContext;
  147.     art3dPaintEffectsBrushCallback( "art3dPaintCtx" );
  148.         
  149.     // Replece the old selection list so that we don't modify Maya's state
  150.     //
  151.     select -r $currSelection;
  152. }
  153.